﻿function [indices,archive]=IMOEAD(chromosome,pop,V,gen,bounds,M,T,min_range, max_range,Time,runs)
pop = round(pop);                                                          
gen = round(gen);                                                          
[W,pop] =  UniformPoint(pop,M/2);                                          
neighour = init_neighbour(W,T);
Z = min(chromosome(:,V+1:V+M));          
fprintf(2,'???????:'),fprintf(2,'%d\n',runs);
W = adjust_vector1(chromosome(:,V+M+1:V+M+2),pop,W);
neighour = init_neighbour(W,T);
tic
flag = 0;
for i = 1:gen
%     fea=0;

    for j = 1:pop                                                          
        newpoint = evolution(chromosome(:,1:V),neighour,j,V,T,i,gen);      
        newpoint = fixnew(newpoint,min_range,max_range);                   
        newpoint = gaussian_mutate(newpoint,V,min_range,max_range);        
        zz = evaluate_constraint(newpoint,M,V);
        Z_new = zz(1:4);
        Z = min([Z;Z_new]);
        nei =  neighour(j,:);
        for l = 1:T
            n = nei(l);                                                    
            [chromosome(n,1:V),chromosome(n,V+1:V+M),chromosome(n,V+M+1:V+M+2),chrom1]=updates1(W(n,:),chromosome(n,1:V),chromosome(n,V+1:V+M),newpoint,Z_new,Z,chromosome(n,V+5:V+6),zz(5:6));  % ?????????
        end
    end
    if ~mod(i,Time) && i < gen
            flag = flag + 1;
            if flag == 1
                Time = 100;
            end
            if all(chromosome(:,V+M+1)==0)
                [distance,index] = crowding_distance2(chromosome(:,V+1:V+M));
                W = Update_weight2(distance,W,index);
                neighour = init_neighbour(W,T);  
            else
                W = adjust_vector1(chromosome(:,V+M+1:V+M+2),pop,W);
                neighour = init_neighbour(W,T); 
            end
    end
    archive(1,1).xy=chromosome; 
    str = strcat('DICMOEAD','chromosome','.mat');
    save(str,'chromosome')
    fprintf('????:%d\n',i);
end
toc
time=toc;
indices=metric(chromosome,M,V,bounds,1);
indices.time(1) = time;
end

